package Controller.Music;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Bean.JoinBean;
import Bean.MusicBean;
import Dao.MusicDao;

public class TopTanListController implements Controller {
	private MusicDao dao;
	public void setDao(MusicDao dao) {
		this.dao = dao;
	}

	@Override
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {

		
		List<JoinBean> top10List = dao.GetTopTanList();
		
		for (JoinBean joinBean : top10List) {
			MusicBean musicBean = joinBean.getMusicBean();
			if(joinBean.getMusicBean().getMs_featuring().equals("없음")){
				musicBean.setMs_featuring("");
				joinBean.setMusicBean(musicBean);
			}else{
				musicBean.setMs_featuring("(feat."+musicBean.getMs_featuring()+")");
				joinBean.setMusicBean(musicBean);
			}
		}
		ModelAndView mav = new ModelAndView();
		mav.setViewName("TOP10List");
		mav.addObject("top10",top10List);
		return mav;
	}
	

}
